home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <!-- ===========================================================
- Category: XSLT
- Sub-category: xsl:call-template
- Author: David Silverlight
- HeadGeek@xmlpitstop.com
- Created: 2001-05-16
- Description:-
- This stylesheet demonstrates the use of xsl:call-template
- by calling multiple templates by name to display different
- HTML views of xslt output.
- ================================================================ -->
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:output method="html" />
-
- <xsl:template match="/">
- <html>
- <head>
- <title>Stylesheet Example</title>
- <style type="text/css"><![CDATA[
- H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
- TD {COLOR: darkblue; FONT-FAMILY: Arial}
- TR { background-color: beige; }
- BODY { background-color: beige; }
- ]]></style>
- </head>
- <body>
- <h1>Employee information sorted by Name and by Hourly rate.</h1>
-
- <!-- The second template that we call displays the employees in employee name order -->
- <xsl:call-template name="ShowEmployeesByName" />
-
- <!-- The second template that we call displays the employees in order of Hourly Rate -->
- <xsl:call-template name="ShowEmployeesByRate" />
- </body>
- </html>
- </xsl:template>
-
- <xsl:template name="ShowEmployeesByName">
- <h2>Employees sorted by Name</h2>
- <!-- Table Header Creation -->
- <table border="1">
- <tr>
- <th>Name</th>
- <th>Department</th>
- <th>Hourly Rate</th>
- <th>Primary Language</th>
- </tr>
- <xsl:for-each select="employees/employee">
- <xsl:sort order="ascending" select="employeename" />
- <tr>
- <td>
- <xsl:value-of select="employeename" />
- </td>
- <td>
- <xsl:value-of select="department" />
- </td>
- <td>
- <xsl:value-of select="hourlyrate" />
- </td>
- <td>
- <xsl:value-of select="primarylanguage" />
- </td>
- </tr>
- </xsl:for-each>
- </table>
- </xsl:template>
-
- <xsl:template name="ShowEmployeesByRate">
- <h2>Employees sorted by hourly rate</h2>
- <table border="1">
- <tr>
- <th>Name</th>
- <th>Department</th>
- <th>Hourly Rate</th>
- <th>Primary Language</th>
- </tr>
- <xsl:for-each select="employees/employee">
- <xsl:sort order="ascending" select="hourlyrate" data-type="number" />
- <tr>
- <td>
- <xsl:value-of select="employeename" />
- </td>
- <td>
- <xsl:value-of select="department" />
- </td>
- <td>
- <xsl:value-of select="hourlyrate" />
- </td>
- <td>
- <xsl:value-of select="primarylanguage" />
- </td>
- </tr>
- </xsl:for-each>
- </table>
- </xsl:template>
- </xsl:stylesheet>